<?php
//smarty库的适配器
namespace wlcat\src\templet;
class SmartyAdapt implements TempletInterface {
    protected $smarty;
    public function __construct()
    {
        $path = empty(C('smarty.path'))  ?
            FRAME_PATH.'src/plugin/smarty/'.C('smarty.version').'/libs/Smarty.class.php'
            : C('smarty.path');
        require_once $path;
        $this->smarty = new \Smarty();
    }

    public function assign($var, $value, ...$param)
    {
        $this->smarty->assign($var, $value);
    }
    public function display($file)
    {
        $this->smarty->display($file);
    }

    public function setTemplateDir($dir)
    {
        $this->smarty->setTemplateDir($dir);
    }

    //设置缓存目录
    public function setCompileDir($dir){
        $this->smarty->setCompileDir($dir);
    }
    //设置缓存目录
    public function setCacheDir($dir){
        $this->smarty->setCacheDir($dir);
    }
    //设置是否缓存
    public function setCache($bool)
    {
        $this->smarty->caching = $bool;
    }
    //设置缓存时间
    public function setCacheTime($time){
        $this->smarty->cache_lifetime = $time;
    }
    //设置是否开启debug
    public function setDebug($bool)
    {
        $this->smarty->debugging = $bool;
    }
}